class Solution {
public:
    bool canThreePartsEqualSum(vector<int>& arr) {
        int sum=accumulate(arr.begin(),arr.end(),0);
        if(sum%3!=0)
            return false;
        else 
            sum/=3;
        int i=0,cnt=0,div=0;
        while(i<arr.size() && cnt<3)
        {
            div+=arr[i];
            i++;
            if(div==sum)
            {
                div=0;
                cnt++;
            }
        }
        return cnt==3;
    }
};